//
//  StatusCell.swift
//  SinaWeibo
//
//  Created by 王佳琳 on 16/2/20.
//  Copyright © 2016年 王佳琳. All rights reserved.
//

import UIKit
import SnapKit

class StatusCell: UITableViewCell {
    
    //添加模型属性
    var status: Status? {
        didSet {
            //设置原创微博的数据模型
            statusOriginalView.status = status
        }
    }

    //xib加载的视图  才会走这个方法
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    //cell的默认的构造方法
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        //自定义操作
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI() {
        //添加子视图  用contentView
        contentView.addSubview(statusOriginalView)
        contentView.addSubview(statusCellBottomView)

        
        //设置约束
        statusOriginalView.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(contentView.snp_left)
            make.right.equalTo(contentView.snp_right)
            make.top.equalTo(contentView.snp_top)
            //设置高度
//            make.height.equalTo(80)
        }
        statusCellBottomView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(statusOriginalView.snp_bottom)
            make.left.equalTo(contentView.snp_left)
            make.right.equalTo(contentView.snp_right)
            //设置高度
            make.height.equalTo(35)
        }

        
        //给contentView添加约束
        contentView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.left.equalTo(self.snp_left)
            make.right.equalTo(self.snp_right)
            //最关键的约束
            make.bottom.equalTo(statusCellBottomView.snp_bottom)

        }
    }
    
    //懒加载子视图
    private lazy var statusOriginalView: StatusCellOriginalView = StatusCellOriginalView()
    //底部视图
    private lazy var statusCellBottomView: StatusCellBottomView = StatusCellBottomView()


}
